﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DTO;
using DAO;

namespace QLDaiLy
{
    public partial class DanhSachDaiLyDangNo :XtraUserControl
    {
        public DanhSachDaiLyDangNo()
        {
            InitializeComponent();
            LoadDanhDanhSachDaiLyDangNo();
        }
        private void LoadDanhDanhSachDaiLyDangNo()
        {

            List<DaiLyDTO> list = new List<DaiLyDTO>();
            list = DaiLyDAO.LoadDanhSachDaiLyDangNo();
            gridDaiLyControl.DataSource = list;
        }

        private void repositoryItemPhieuThu_Click(object sender, EventArgs e)
        {
            string MaDaiLy = gridViewDanhSachDaiLy.GetRowCellValue(gridViewDanhSachDaiLy.FocusedRowHandle, gridViewDanhSachDaiLy.Columns["MaDaiLy"]).ToString();
            string TenDaiLy = gridViewDanhSachDaiLy.GetRowCellValue(gridViewDanhSachDaiLy.FocusedRowHandle, gridViewDanhSachDaiLy.Columns["TenDaiLy"]).ToString();
            string NoCuaDaiLy = gridViewDanhSachDaiLy.GetRowCellValue(gridViewDanhSachDaiLy.FocusedRowHandle, gridViewDanhSachDaiLy.Columns["NoCuaDaiLy"]).ToString();

            TableLayoutPanel tb = (TableLayoutPanel)this.Parent;
            tb.Controls.Remove(tb.GetControlFromPosition(0, 1));
            PhieuThuTien frm = new PhieuThuTien(MaDaiLy, TenDaiLy, NoCuaDaiLy);
            tb.Controls.Add(frm, 0, 1);
        }

        private void gridViewDanhSachDaiLy_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
        {
            if (e.IsGetData)
            {
                e.Value = QLDaiLy.Properties.Resources.ThuTien;
            }
        }
    }
}
